import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANEsMNoX8MfP32VxFBz+9HNlfgYpwqID\n" +
  "U2T25/Lf2WZubB842V8O6UkKPPv2y1DIdl2U/l7oYT6Ee3UgsAKJE30CAwEAAQ==";

const privateKey =
  "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA0Sww2hfwx8/fZXEU\n" +
  "HP70c2V+BinCogNTZPbn8t/ZZm5sHzjZXw7pSQo8+/bLUMh2XZT+XuhhPoR7dSCw\n" +
  "AokTfQIDAQABAkEAw8iXGSvbZUr+kJac+t7ws6pFoUMpODfgsNoiFMTNWf9CIqD9\n" +
  "jICNAA+eu2cqsFtUorhAckx9NrUuZe43PnYhQQIhAP1IkxNR4YMaG9zwiFCQywXL\n" +
  "q7FwldC3k5HIyKpi/c3ZAiEA02qA8o7TTJcHJy7a6zKuYm43pUckxL9BFgfv97+O\n" +
  "WEUCIDVpJHqifaejzdRddKFopydlt6MHVtBYpenMKWSk01ihAiBh+8yDnppjtuOD\n" +
  "z3164GReDkMQAOcToKhjs44OPuOUGQIhAIe5p9CGbzt3r2aH8EZwFWlarVSVIzkM\n" +
  "lMOAU9oZOogS";


// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

